require(["jquery"], function() {
	$("#footer_weixin").on("mouseover", function() {
		$(".popover").fadeIn(100)
	}).on("mouseout", function() {
		$(".popover").hide()
	})
}), require(["jquery"], function() {
	$("#div_city").on("mouseover", function() {
		$("#cities").css("display", "block")
	}), $("#div_city").on("mouseout", function() {
		$("#cities").css("display", "none")
	})
}), require(["jquery", "jquery.placeholder"], function() {
	$("input, textarea").placeholder()
}), require(["jquery", "bootstrap", "jquery.fullscreen"], function($) {
	function fillIntentBuySeriesSelector(brand_id) {
		brand_id && $.getJSON("/index.php?d=api&c=car_metainfo&m=index&type=get_series_by_brand_id&brand_id=" + brand_id, function(result) {
			if (0 === result.status && result.data) {
				var items = ["<option value=''>车系</option>"];
				$.each(result.data, function(key, val) {
					items.push("<option value='" + val.series_id + "'>" + val.series_name + "</option>")
				}), $("#intent_buy_series").html(items.join(""))
			}
		})
	}
	function share() {
		!
		function(s, d, e) {
			function a() {
				window.open([f, p].join(""), "mb", ["toolbar=0,status=0,resizable=1,width=620,height=450,left=", (s.width - 620) / 2, ",top=", (s.height - 450) / 2].join("")) || (u.href = [f, p].join(""))
			}
			try {} catch (e) {}
			var f = "http://v.t.sina.com.cn/share/share.php?",
				u = location.href,
				p = ["url=", e(u), "&title=", e(window.sharetitle), "&appkey=2924220432", "&pic=", e(window.shareUrl)].join("");
			/Firefox/.test(navigator.userAgent) ? setTimeout(a, 0) : a()
		}(screen, document, encodeURIComponent)
	}
	window.onload = function() {
		var promo_uuid = "promo_uuid"; - 1 === document.cookie.indexOf(promo_uuid) && (document.cookie = promo_uuid + "=" + Math.floor(1e6 * Math.random()) + new Date + ";max-age=604800", $("#promo_layer_modal").fullscreen({
			backdrop: "static",
			show: !0
		}), $(".modal-backdrop").on("click", function() {
			$(".modal-backdrop").css("display", "none"), $("#promo_layer_modal").css("display", "none")
		}))
	}, $("#intent_buy_button").on("click", function() {
		$("#intent_buy_modal").fullscreen({
			backdrop: "static",
			show: !0
		})
	}), $("#intent_buy_mobile_number").on("focus", function() {
		$(this).data("editing", "true")
	}).on("change", function() {
		$(this).data("editing", "true")
	}).on("blur", function() {
		$(this).data("editing", "false"), $(this).parent().removeClass("error"), $(this).data("error", "false");
		var val = $.trim($(this).val()),
			reMobile = /^1[34578][0-9]{9}$/;
		val ? reMobile.test(val) ? $(this).parent().find("p").remove() : ($(this).parent().addClass("error"), $(this).data("error", "true"), $(this).parent().find("p").remove(), $(this).parent().append("<p>*手机号格式不正确</p>")) : $(this).parent().find("p").remove()
	}), $.getJSON("/index.php?d=api&c=car_metainfo&m=index&type=get_brands", function(result) {
		var items = ["<option value=''>品牌</option>"];
		0 === result.status && result.data && $.each(result.data, function(key, val) {
			items.push("<option value='" + val.brand_id + "'>" + val.first_char + " " + val.brand_name + "</option>")
		}), $("#intent_buy_brand").html(items.join(""))
	}), $("#intent_buy_brand").on("change", function() {
		var val = $(this).val();
		fillIntentBuySeriesSelector(val)
	}), $("#intent_buy_submit").on("click", function() {
		var $inBrand = $("#intent_buy_brand"),
			$inSeries = $("#intent_buy_series"),
			$inMobile = $("#intent_buy_mobile_number"),
			$inSource = $("#buy_phone_source"),
			$inSell = $("#sell_source"),
			$inCity = $("#intent_buy_city"),
			val = $inBrand.val() + $inSeries.val() + $inMobile.val() + $inSell.val() + $inCity.val();
		if (!$inMobile.val() || "true" === $inMobile.data("error")) return void $inMobile.focus();
		if (val !== $(this).data("submit")) {
			$(this).data("submit", val);
			var data = {
				car_id: $(".detail-wrapper").data("id"),
				mobile_number: $.trim($inMobile.val()),
				car_series: $inSeries.val(),
				brand: $inBrand.val(),
				phone_source: $inSource.val(),
				sell_source: $inSell.val(),
				city: $inCity.val()
			};
			$.post("/index.php?d=api&c=intent&m=buy", data, function() {}), $("#intent_buy_modal").find(".form-wrapper").addClass("confirm").html("<h2>您的需求已经提交成功</h2><p>我们会尽快帮您找到合适的个人车源并安排看车</p>")
		}
	}), $("#share_button").on("click", function() {
		$("#share_modal").fullscreen({
			backdrop: "static",
			show: !0
		})
	}), function() {
		var share_img;
		share_img = document.getElementById("detail_img") ? document.getElementById("detail_img").src : document.getElementById("sales_img") ? "http://rrcdn.qiniudn.com/dist/pc/images/sales_img-c0ae3105.png" : "http://rrcdn.qiniudn.com/dist/pc/images/all_img-9f334e0a.png";
		var share_title = document.title,
			share_content = document.getElementById("share_content").value,
			p = {
				url: location.href,
				pics: share_img,
				desc: share_content,
				title: share_title
			},
			s = [];
		for (var i in p) s.push(i + "=" + encodeURIComponent(p[i] || ""));
		var qq_zone = document.getElementById("pc_qq_zone");
		qq_zone.href = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?" + s.join("&")
	}(), $("#pc_sina_weibo").on("click", function() {
		window.sharetitle = document.getElementById("share_content").value;
		var share_img;
		share_img = document.getElementById("detail_img") ? document.getElementById("detail_img").src : document.getElementById("sales_img") ? "http://rrcdn.qiniudn.com/dist/pc/images/sales_img-c0ae3105.png" : "http://rrcdn.qiniudn.com/dist/pc/images/all_img-9f334e0a.png", window.shareUrl = share_img, share()
	}), $(document).ready(function() {
		$("#LXB_CLOSE_BTN").on("click", function() {
			$("#LXB_CONTAINER").toggleClass("shouldShow")
		})
	})
}), require(["jquery", "jquery.scroll2Top"], function() {
	$("#scroll2Top").scroll2Top({
		appearAt: -10,
		scrollSpeed: 500
	})
});